<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$basic=$this->plugin_setting('basic');
$return['basic']=$basic;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return['diy']=$this->plugin_setting('diy');
$return['vip']=$this->plugin_setting('vip');
if($_RQ['op']=='main'){
	/*******main*******/
	//首页轮播图
	//首页推荐服务人员和项目
	$worker_show=pdo_getall('jy_yuyue_worker',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>0,'isshow'=>'1','status'=>'1','islock'=>'0'));
	if($worker_show){
		foreach($worker_show as &$item){
			$num1=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'worker_id'=>$item['id'],'status'=>'1'));
			$num2=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'worker_id'=>$item['id'],'status'=>'2'));
			$num3=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'worker_id'=>$item['id'],'status'=>'4'));
			$item['num']=$num1+$num2+$num3;
		}
	}
	$serve_show=pdo_getall('jy_yuyue_serve',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>0,'isshow'=>'1','status'=>'1'));
	if($serve_show){
		foreach($serve_show as &$item){
			$num1=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$item['id'],'status'=>'1'));
			$num2=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$item['id'],'status'=>'2'));
			$num3=pdo_count('jy_yuyue_order',array('uniacid'=>$_SESSION['uniacid'],'serve_id'=>$item['id'],'status'=>'4'));
			$item['num']=$num1+$num2+$num3;
		}
	}
	//公告列表
	$pindex = max(1, intval($post['page']));
	$psize = 10;
	$total='';
	$notice_list = pdo_getslice('jy_yuyue_notice',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array($pindex,20),$total,array('id','title','createtime'),'','id desc');
	if($notice_list){
		foreach($notice_list as &$notice){
			if($_SESSION['os']=='windows'){
				$notice['createtime']=date('m-d',$notice['createtime']);
			}else{
				$notice['createtime']=date('Y-m-d h:i',$notice['createtime']);
			}
		}
	}
	$return['notice_list']=$notice_list;
	//检查用户是否激活
	$user=pdo_get('jy_yuyue_user',array('uniacid'=>$_SESSION['uniacid'],'id'=>$_SESSION['uid']));
	//检查用户到期时间
	if($user['viptime']<time()){
		pdo_update('jy_yuyue_user',array('viptime'=>0,'isvip'=>0),array('uniacid'=>$_SESSION['uniacid'],'id'=>$_SESSION['uid']));
	}
	$return['worker_show']=$worker_show;
	$return['serve_show']=$serve_show;
	$return['image']=$basic['image'];
	$return['user']=$user;
	set_html('title',$basic['name']?:'在线预约');
	exi($return);
}